package com.huifaapp.mall.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.huifaapp.mall.R;
import com.huifaapp.mall.activity.Homefragment.ReturnafterActivity;
import com.huifaapp.mall.bean.ReturnafterBean;
import com.huifaapp.mall.uitils.UtilsImage;

import java.util.List;

/**
 * Created by mac on 2017/12/12.
 */

public class ApplicationsRecordAdapter extends RecyclerView.Adapter <ApplicationsRecordAdapter.MyViewHolder> {
    private Context context;
    private List<ReturnafterBean.DataBean> list;
    private ReturnafterBean.DataBean.GoodBean goodBean;
    private MyViewHolder myViewHolder;
    int position;


    public ApplicationsRecordAdapter(Context context, List<ReturnafterBean.DataBean> list) {
        this.context = context;
        this.list = list;
        this.goodBean = goodBean;
        Log.e("售后列表",list+"");
    }

    @Override
    public ApplicationsRecordAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.applirecord_item, null);
        goodBean = list.get(position).getGood();
        ApplicationsRecordAdapter.MyViewHolder myViewHolder = new ApplicationsRecordAdapter.MyViewHolder(view);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(ApplicationsRecordAdapter.MyViewHolder holder, int position) {

        holder.dd_num.setText(list.get(position).getAfterSaleId()+"");

        holder.shop_yj.setText("¥"+list.get(position).getGood().getPrice()+"");
        holder.shop_xj.setText("¥"+list.get(position).getGood().getOrginPrice()+"");
        holder.shop_num.setText("x"+list.get(position).getGood().getCount()+"");
        String size = list.get(position).getGood().getParam().getSize();
        String color = list.get(position).getGood().getParam().getColor();
        holder.shop_size.setText("颜色分类:  " + color + ";尺寸:  " + size);
        holder.shop_yf.setText("(含运费¥"+list.get(position).getExpressFee()+")");
        holder.shop_gj.setText("共计"+list.get(position).getTotalCount()+"件商品");
        holder.shop_hj.setText("合计:  ¥"+list.get(position).getTotalAmount()+"");
//        Glide.with(context).load(list.get(position).getGood().getGoodsImg()).into(holder.shop_im);
        holder.shop_name.setText(list.get(position).getGood().getGoodsName());
        UtilsImage.uploadimageview(holder.shop_im,list.get(position).getGood().getGoodsImg(),"null",context);
        if (list.get(position).getDealState().equals("001")){
            holder.shop_hh.setText("退款中");
            holder.shop_xg.setText("退款中");
            holder.shop_xg1.setText("您的服务已申请成功，待退款中");
        }else if (list.get(position).getDealState().equals("002")){
            holder.shop_hh.setText("换货关闭/退货关闭");
            holder.shop_xg.setText("换货关闭/退货关闭");
            holder.shop_xg1.setText("您的服务已完成");
        }else if (list.get(position).getDealState().equals("003")){
            holder.shop_hh.setText("待处理");
            holder.shop_xg.setText("待处理");
            holder.shop_xg1.setText("您的服务已申请成功，待处理中");
        }else if (list.get(position).getDealState().equals("004")){
            holder.shop_hh.setText("售后拒绝");
            holder.shop_xg.setText("售后拒绝");
            holder.shop_xg1.setText("您的服务已拒绝");
        }else if (list.get(position).getDealState().equals("005")){
            holder.shop_hh.setText("同意换货填写物流");
            holder.shop_xg.setText("同意换货填写物流");
            holder.shop_xg1.setText("您的申请已同意，请填写物流信息");
        }else if (list.get(position).getDealState().equals("006")){
            holder.shop_hh.setText("退款成功");
            holder.shop_xg.setText("退款成功");
            holder.shop_xg1.setText("您的服务已完成，退款成功");
        }else if (list.get(position).getDealState().equals("007")){
            holder.shop_hh.setText("撤销申请");
            holder.shop_xg.setText("撤销申请");
            holder.shop_xg1.setText("您的服务已撤销申请");
        }else if (list.get(position).getDealState().equals("008")){
            holder.shop_hh.setText("已审核");
            holder.shop_xg.setText("已审核");
            holder.shop_xg1.setText("您的服务已审核,请等待");
        }else if (list.get(position).getDealState().equals("009")){
            holder.shop_hh.setText("已完成");
            holder.shop_xg.setText("已完成");
            holder.shop_xg1.setText("您的服务已完成");
        }






    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {


        TextView dd_num,shop_name,shop_yj,shop_xj,shop_num,shop_size,
                shop_gj,shop_hj,shop_yf,shop_hh,shop_xg,shop_xg1;
        ImageView shop_im;



        public MyViewHolder(View itemView) {
            super(itemView);
            shop_hh = (TextView) itemView.findViewById(R.id.applirecord_dealhh);
            dd_num = (TextView) itemView.findViewById(R.id.applirecord_returnid);
            shop_name = (TextView) itemView.findViewById(R.id.applirecord_shopname);
            shop_yj = (TextView) itemView.findViewById(R.id.applirecord_yj);
            shop_xj = (TextView) itemView.findViewById(R.id.applirecord_xj);
            shop_num = (TextView) itemView.findViewById(R.id.applirecord_num);
            shop_size = (TextView) itemView.findViewById(R.id.applirecord_size);
            shop_gj = (TextView) itemView.findViewById(R.id.applirecord_gj);
            shop_im = (ImageView) itemView.findViewById(R.id.applirecord_shopim);
            shop_hj = (TextView) itemView.findViewById(R.id.applirecord_hj);
            shop_yf = (TextView) itemView.findViewById(R.id.applirecord_hyf);
            shop_xg = (TextView) itemView.findViewById(R.id.applirecord_bottomxg);
            shop_xg1 = (TextView) itemView.findViewById(R.id.applirecord_bottomxg1);
        }
    }

    {
    }
}